//
//  ProductViewController.m
//  SDHuiYuShoping
//
//  Created by luojiao on 2017/5/2.
//  Copyright © 2017年 luojiao. All rights reserved.
//

#import "ProductViewController.h"
#import "DetailViewController.h"
#import "ProductImageVC.h"
#import "SDShopingVC.h"

@interface ProductViewController ()<YPTabBarDelegate>

@end

@implementation ProductViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBarController.tabBar.hidden = YES;
    [self setButtonBgImage];
    
    CGSize screenSize = [UIScreen mainScreen].bounds.size;
    [self setTabBarFrame:CGRectMake(0, 20, screenSize.width, 44)
        contentViewFrame:CGRectMake(0, 64, screenSize.width, screenSize.height - 64 - 50)];
    self.tabBar.delegate = self;
    self.tabBar.badgeTitleColor = [UIColor redColor];
    //处于未编辑状态字体颜色
    self.tabBar.itemTitleColor = [UIColor whiteColor];
    //处于编辑状态字体颜色
    self.tabBar.itemTitleSelectedColor = [UIColor whiteColor];
    self.tabBar.itemTitleFont = [UIFont systemFontOfSize:17];
    self.tabBar.itemTitleSelectedFont = [UIFont systemFontOfSize:22];
    //设置第一个头部字体的位置
    self.tabBar.leftAndRightSpacing = 120;
    
    self.tabBar.itemFontChangeFollowContentScroll = YES;
    self.tabBar.itemSelectedBgScrollFollowContent = YES;
    //设置滑动线条颜色
    self.tabBar.itemSelectedBgColor = [UIColor whiteColor];
    
    //红色字体透明度
    [self.tabBar setItemSelectedBgInsets:UIEdgeInsetsMake(40, 15, 0, 15) tapSwitchAnimated:NO];
    //    字体下面的
    [self.tabBar setScrollEnabledAndItemFitTextWidthWithSpacing:40];
    [self setContentScrollEnabledAndTapSwitchAnimated:NO];
    self.loadViewOfChildContollerWhileAppear = YES;
    
    [self initViewControllers];
}


- (void)initViewControllers {
    DetailViewController *controller1 = [[DetailViewController alloc] init];
    controller1.yp_tabItemTitle = @"商品";
    
    ProductImageVC *controller2 = [[ProductImageVC alloc] init];
    controller2.yp_tabItemTitle = @"详情";
    
    self.viewControllers = [NSMutableArray arrayWithObjects:controller1,controller2, nil];
}

- (void)setButtonBgImage
{
    [self.collectionButton setImage:[UIImage imageNamed:@"collection_btn"] forState:UIControlStateNormal];
    [self.collectionButton setImageEdgeInsets:UIEdgeInsetsMake(-10, 0, 0, -50)];
    [self.collectionButton setTitle:@"收藏" forState:UIControlStateNormal];
    [self.collectionButton setTitleEdgeInsets:UIEdgeInsetsMake(30, 0, 0, -10)];
    
    [self.shoppingCar setImage:[UIImage imageNamed:@"shop_btn_def"] forState:UIControlStateNormal];
    [self.shoppingCar setImageEdgeInsets:UIEdgeInsetsMake(-10, 0, 0, -50)];
    [self.shoppingCar setTitle:@"购物车" forState:UIControlStateNormal];
    [self.shoppingCar setTitleEdgeInsets:UIEdgeInsetsMake(30, -10, 0, 0)];
    
//    [self.joinShoppingButton setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//    [self.joinShoppingButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    [self.joinShoppingButton setTitle:@"加入购物车" forState:UIControlStateNormal];
    [self.joinShoppingButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
    
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //设置状态栏颜色
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}


#pragma mark -- buttonClick
- (IBAction)collectionButton:(id)sender
{
    
}
- (IBAction)shoppingCarButton:(id)sender
{
    SDShopingVC *shopingVC = [[SDShopingVC alloc] init];
    [self.navigationController pushViewController:shopingVC animated:YES];
}
- (IBAction)joinShoppingButton:(id)sender
{
    
}


#pragma mark - YPTabBarDelegate

-(void)backButtonClick
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
